package cn.iocoder.yudao.module.movie.factory;

import cn.iocoder.yudao.framework.common.util.spring.SpringUtils;
import cn.iocoder.yudao.module.movie.enums.MovieInfEnum;
import cn.iocoder.yudao.module.movie.serive.movieInf.MovieInfService;

import java.util.Map;

/**
 * <p>  </p>
 */

public class MovieInfFactory {
    private MovieInfFactory() {
    }
    public static MovieInfService getMovieInfService(MovieInfEnum movieInfType) {
        Map<String, MovieInfService> serviceMap = SpringUtils.getBeansOfType(MovieInfService.class);
        if (serviceMap == null || serviceMap.isEmpty()) {
            throw new IllegalArgumentException("Invalid movieInfType: " + movieInfType);
        }
        // 遍历
        for (Map.Entry<String, MovieInfService> entry : serviceMap.entrySet()) {
            MovieInfService service = entry.getValue();
            if (service.getMovieInfType().equals(movieInfType)) {
                return service;
            }
        }
        throw new IllegalArgumentException("Invalid movieInfType: " + movieInfType);
    }
}
